package mypackage;

import java.util.Scanner;

public class Id {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入18位的身份证号");
        int year=0,month=0,day=0;
        char gender='中';
        while(true){
            String id=sc.next();
            if(id.length()==18){
                String sex=id.substring(id.length()-1,id.length());
                int num=sex.charAt(0)-'0';
                if((num&1)==0){
                    gender='女';
                }else{
                    gender='男';
                }
                String birth=id.substring(6,13);
                String yearstr=birth.substring(0,4);
                for (int i = 0; i < yearstr.length(); i++) {
                    year=year*10+(int)(yearstr.charAt(i)-'0');
                }
                String monthstr=birth.substring(4,6);
                for (int i = 0; i < monthstr.length(); i++) {
                    month=month*10+(int)(monthstr.charAt(i)-'0');
                }
                String daystr=birth.substring(6);
                for (int i = 0; i < daystr.length(); i++) {
                    day=day*10+(int)(daystr.charAt(i)-'0');
                }
                break;
            }else{
                System.out.println("输出的身份证不合法,请重新输入");
            }
        }
        System.out.println("您的出生日为:"+year+"年"+month+"月"+day+"日"+"性别是:"+gender);
    }
}
